<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生日期" prop="birth">
        <el-date-picker clearable
          v-model="queryParams.birth"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择出生日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="年龄" prop="age">
        <el-input
          v-model="queryParams.age"
          placeholder="请输入年龄"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身高" prop="height">
        <el-input
          v-model="queryParams.height"
          placeholder="请输入身高"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生肖" prop="chineseZodiac">
        <el-input
          v-model="queryParams.chineseZodiac"
          placeholder="请输入生肖"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="星座" prop="constellation">
        <el-input
          v-model="queryParams.constellation"
          placeholder="请输入星座"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="户口情况" prop="registered">
        <el-input
          v-model="queryParams.registered"
          placeholder="请输入户口情况"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学历" prop="educationBackground">
        <el-input
          v-model="queryParams.educationBackground"
          placeholder="请输入学历"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="月收入" prop="monthlyIncome">
        <el-input
          v-model="queryParams.monthlyIncome"
          placeholder="请输入月收入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:info:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:info:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:info:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:info:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" />
      <el-table-column label="姓名" align="center" prop="userName" />
<!--      <el-table-column label="身份证" align="center" prop="idCard" />-->
      <el-table-column label="政治面貌" align="center" prop="politics" />
      <el-table-column label="出生日期" align="center" prop="birth" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.birth, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="性别" align="center" prop="sex">
        <template slot-scope="scope">
          <span>{{ getUserSex(scope.row.sex) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="身高" align="center" prop="height" />
<!--      <el-table-column label="生肖" align="center" prop="chineseZodiac" />-->
<!--      <el-table-column label="照片" align="center" prop="images" />-->
<!--      <el-table-column label="星座" align="center" prop="constellation" />-->
<!--      <el-table-column label="体重" align="center" prop="weight" />-->
      <el-table-column label="民族" align="center" prop="nation" />
      <el-table-column label="户口情况" align="center" prop="registered" />
<!--      <el-table-column label="健康状态" align="center" prop="healthy" />-->
      <el-table-column label="学历" align="center" prop="educationBackground" >
        <template slot-scope="scope">
          <span>{{ getUserEducationBackground(scope.row.educationBackground) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="婚姻状态" align="center" prop="marriageStatus">
        <template slot-scope="scope">
          <span>{{ getUserMarriage(scope.row.marriageStatus) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" width="150" prop="createTime" />
<!--      <el-table-column label="月收入" align="center" prop="monthlyIncome" />-->
<!--      <el-table-column label="年收入" align="center" prop="annualIncome" />-->
<!--      <el-table-column label="住房情况" align="center" prop="housing" />-->
<!--      <el-table-column label="备车情况" align="center" prop="carStatus" />-->
<!--      <el-table-column label="性格" align="center" prop="nature" />-->
<!--      <el-table-column label="联系方式1" align="center" prop="phone1" />-->
<!--      <el-table-column label="联系方式2" align="center" prop="phone2" />-->
<!--      <el-table-column label="爱好" align="center" prop="hobby" />-->
<!--      <el-table-column label="qq号" align="center" prop="qq" />-->
<!--      <el-table-column label="微信号" align="center" prop="weChat" />-->
<!--      <el-table-column label="电子邮箱" align="center" prop="mail" />-->
<!--      <el-table-column label="地址" align="center" prop="address" />-->
<!--      <el-table-column label="特长" align="center" prop="strongPoint" />-->
      <el-table-column label="操作"  width="180px" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            v-hasPermi="['system:info:view']"
          >详情</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:info:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:info:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改客户管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="姓名" prop="userName">
          <el-input v-model="form.userName" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="身份证" prop="idCard">
          <el-input v-model="form.idCard" placeholder="请输入身份证" />
        </el-form-item>
        <el-form-item label="政治面貌" prop="politics">
          <el-input v-model="form.politics" placeholder="请输入政治面貌" />
        </el-form-item>
        <el-form-item label="出生日期" prop="birth">
          <el-date-picker clearable
            v-model="form.birth"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择出生日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="年龄" prop="age">
          <el-input v-model="form.age" placeholder="请输入年龄" />
        </el-form-item>
        <el-form-item label="性别" prop="sex">
          <template>
            <el-select v-model="form.sex" placeholder="请选择婚姻状态">
              <el-option
                v-for="item in sexList"
                :key="item.id"
                :label="item.value"
                :value="item.id">
              </el-option>
            </el-select>
          </template>
        </el-form-item>
        <el-form-item label="身高" prop="height">
          <el-input v-model="form.height" placeholder="请输入身高" />
        </el-form-item>
        <el-form-item label="生肖" prop="chineseZodiac">
          <el-input v-model="form.chineseZodiac" placeholder="请输入生肖" />
        </el-form-item>
        <el-form-item label="照片" prop="images">
          <el-upload
            class="avatar-uploader"
            action="http://localhost/dev-api/business/info/imageUpload"
            :show-file-list="false"
            :on-success="handleAvatarSuccess"
            :before-upload="beforeAvatarUpload">
            <img v-if="imageUrl" :src="imageUrl" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
<!--            <span class="demonstration">{{ fit }}</span>https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg-->
          </el-upload>
        </el-form-item>
        <el-form-item label="星座" prop="constellation">
          <el-input v-model="form.constellation" placeholder="请输入星座" />
        </el-form-item>
        <el-form-item label="体重" prop="weight">
          <el-input v-model="form.weight" placeholder="请输入体重" />
        </el-form-item>
        <el-form-item label="民族" prop="nation">
          <el-input v-model="form.nation" placeholder="请输入民族" />
        </el-form-item>
        <el-form-item label="户口情况" prop="registered">
          <el-input v-model="form.registered" placeholder="请输入户口情况" />
        </el-form-item>
        <el-form-item label="健康状态" prop="healthy">
          <el-input v-model="form.healthy" placeholder="请输入健康状态" />
        </el-form-item>
        <el-form-item label="学历" prop="educationBackground">
          <template>
            <el-select v-model="form.educationBackground" placeholder="请选择婚姻状态">
              <el-option
                v-for="item in educationBackgroundList"
                :key="item.id"
                :label="item.value"
                :value="item.id">
              </el-option>
            </el-select>
          </template>
        </el-form-item>
        <el-form-item label="月收入" prop="monthlyIncome">
          <el-input v-model="form.monthlyIncome" placeholder="请输入月收入" />
        </el-form-item>
        <el-form-item label="年收入" prop="annualIncome">
          <el-input v-model="form.annualIncome" placeholder="请输入年收入" />
        </el-form-item>
        <el-form-item label="住房情况" prop="housing">
          <el-input v-model="form.housing" placeholder="请输入住房情况" />
        </el-form-item>
        <el-form-item label="性格" prop="nature">
          <el-input v-model="form.nature" placeholder="请输入性格" />
        </el-form-item>
        <el-form-item label="婚姻状态" prop="marriageStatus">
          <template>
            <el-select v-model="form.marriageStatus" placeholder="请选择婚姻状态">
              <el-option
                v-for="item in marriageStatusList"
                :key="item.id"
                :label="item.value"
                :value="item.id">
              </el-option>
            </el-select>
          </template>
        </el-form-item>
        <el-form-item label="联系方式1" prop="phone1">
          <el-input v-model="form.phone1" placeholder="请输入联系方式1" />
        </el-form-item>
        <el-form-item label="联系方式2" prop="phone2">
          <el-input v-model="form.phone2" placeholder="请输入联系方式2" />
        </el-form-item>
        <el-form-item label="爱好" prop="hobby">
          <el-input v-model="form.hobby" placeholder="请输入爱好" />
        </el-form-item>
        <el-form-item label="qq号" prop="qq">
          <el-input v-model="form.qq" placeholder="请输入qq号" />
        </el-form-item>
        <el-form-item label="微信号" prop="weChat">
          <el-input v-model="form.weChat" placeholder="请输入微信号" />
        </el-form-item>
        <el-form-item label="电子邮箱" prop="mail">
          <el-input v-model="form.mail" placeholder="请输入电子邮箱" />
        </el-form-item>
        <el-form-item label="地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入地址" />
        </el-form-item>
        <el-form-item label="特长" prop="strongPoint">
          <el-input v-model="form.strongPoint" placeholder="请输入特长" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog title="个人详情" :visible.sync="viewInfoVisible">
      <div class="block">
        <el-image :src="form.images" style="width: 178px; height: 178px"></el-image>
      </div>
      <br>
      <el-descriptions class="margin-top" title="" :column="3" size="1" border>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user"></i>
            姓名
          </template>
          {{form.userName}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-bank-card"></i>
            身份证
          </template>
          {{form.idCard}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-user-solid"></i>
            性别
          </template>
          {{getUserSex(form.sex)}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            政治面貌
          </template>
          {{form.politics}}
        </el-descriptions-item>
        <el-descriptions-item>
<!--          <el-tag size="small">出生日期</el-tag>-->
          <template slot="label">
            <i class="el-icon-tickets"></i>
            出生日期
          </template>
          <span>{{ parseTime(form.birth, '{y}-{m}-{d}') }}</span>
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            年龄
          </template>
          {{form.age}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            身高
          </template>
          {{form.height}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            生肖
          </template>
          {{form.chineseZodiac}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-magic-stick"></i>
            星座
          </template>
          {{form.constellation}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            体重
          </template>
          {{form.weight}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            民族
          </template>
          {{form.nation}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            户口情况
          </template>
          {{form.registered}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            健康状态
          </template>
          {{form.healthy}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            学历
          </template>
          {{getUserEducationBackground(form.educationBackground)}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-document"></i>
            婚姻状态
          </template>
          {{getUserMarriage(form.marriageStatus)}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-coin"></i>
            月收入
          </template>
          {{form.monthlyIncome}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-coin"></i>
            年收入
          </template>
          {{form.annualIncome}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-house"></i>
            住房情况
          </template>
          {{form.housing}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-truck"></i>
            备车情况
          </template>
          {{form.carStatus}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            性格
          </template>
          {{form.nature}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            联系方式1
          </template>
          {{form.phone1}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-mobile-phone"></i>
            联系方式2
          </template>
          {{form.phone2}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            爱好
          </template>
          {{form.hobby}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            qq号
          </template>
          {{form.qq}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-chat-dot-round"></i>
            微信号
          </template>
          {{form.weChat}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            电子邮箱
          </template>
          {{form.mall}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-tickets"></i>
            特长
          </template>
          {{form.strongPoint}}
        </el-descriptions-item>
        <el-descriptions-item>
          <template slot="label">
            <i class="el-icon-location-outline"></i>
            联系地址
          </template>
          {{form.address}}
        </el-descriptions-item>
      </el-descriptions>
    </el-dialog>
  </div>
</template>

<script>
import { listInfo, getInfo, delInfo, addInfo, updateInfo,imageUpload } from "@/api/business/info";

export default {
  name: "Info",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户管理表格数据
      infoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: null,
        idCard: null,
        politics: null,
        birth: null,
        sex: null,
        age: null,
        height: null,
        chineseZodiac: null,
        images: null,
        constellation: null,
        weight: null,
        nation: null,
        registered: null,
        healthy: null,
        educationBackground: null,
        marriageStatus: null,
        monthlyIncome: null,
        annualIncome: null,
        housing: null,
        carStatus: null,
        nature: null,
        phone1: null,
        phone2: null,
        hobby: null,
        qq: null,
        weChat: null,
        mail: null,
        address: null,
        strongPoint: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      marriageStatusList:[
        {
          id: 1,
          value: '未婚'
        },
        {
          id: 2,
          value: '离异'
        },
        {
          id: 3,
          value: '已婚'
        }
      ],
      educationBackgroundList:[
        {
          id: 1,
          value: '小学'
        },
        {
          id: 2,
          value: '初中'
        },
        {
          id: 3,
          value: '高中'
        },
        {
          id: 4,
          value: '中专'
        },
        {
          id: 5,
          value: '大专'
        },
        {
          id: 6,
          value: '本科'
        },
        {
          id: 7,
          value: '研究生'
        },
        {
          id: 8,
          value: '博士'
        }
      ],
      sexList:[
        {
          id: 1,
          value: '男'
        },
        {
          id: 2,
          value: '女'
        }
      ],
      imageUrl: '',
      viewInfoVisible:false
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询客户管理列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userName: null,
        idCard: null,
        politics: null,
        birth: null,
        sex: null,
        age: null,
        height: null,
        chineseZodiac: null,
        images: null,
        constellation: null,
        weight: null,
        nation: null,
        registered: null,
        healthy: null,
        educationBackground: null,
        marriageStatus: null,
        monthlyIncome: null,
        annualIncome: null,
        housing: null,
        carStatus: null,
        nature: null,
        phone1: null,
        phone2: null,
        hobby: null,
        qq: null,
        weChat: null,
        mail: null,
        address: null,
        strongPoint: null,
        createTime: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.imageUrl="";
      this.open = true;
      this.title = "添加客户管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getInfo(id).then(response => {
        this.form = response.data;
        console.log("图片路径：", this.form.images);
        this.imageUrl = this.form.images;
        this.open = true;
        this.title = "修改客户管理";
      });
    },
    /** 详情请
     *
     */
    handleView(row){
      this.viewInfoVisible = true;
      const id = row.id
      getInfo(id).then(response => {
        this.form = response.data;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          // if (this.imageUrl !=null){
          //   this.form.images = this.imageUrl;
          // }
          // console.log("路径：", this.form.images);
          if (this.form.id != null) {

            updateInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除客户管理编号为"' + ids + '"的数据项？').then(function() {
        return delInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/info/export', {
        ...this.queryParams
      }, `info_${new Date().getTime()}.xlsx`)
    },
    // 覆盖默认的上传行为
    requestUpload(file) {
      const formData = new FormData();
      formData.append('file', file);
      // formData.append("avatarfile", data, this.options.filename);
      console.log("调用了上传方法！")
      imageUpload(formData).then(response => {
        this.$modal.msgSuccess("上传成功");
        this.imageUrl = response.data.url;
      });
    },
    handleAvatarSuccess(res, file) {
      console.log("返回参数",res.msg)
      this.imageUrl =  URL.createObjectURL(file.raw);
      this.form.images = res.msg;
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },
    getUserSex(sex){
      if (sex == 1){
        return "男";
      }else {
        return "女";
      }
    },
    getUserMarriage(marriage){
      if (marriage == 1){
        return "未婚";
      }else if (marriage == 2) {
        return "离异";
      }else {
        return "已婚";
      }
    },
    getUserEducationBackground(educationBackground){
      switch (educationBackground) {
        case 1:
          return "小学";
        case 2:
          return "初中";
        case 3:
          return "高中";
        case 4:
          return "中专";
        case 5:
          return "大专";
        case 6:
          return "本科";
        case 7:
          return "研究生";
        case 8:
          return "博士";
        default:
          return "";
      }
    },
  }
};
</script>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
